package sketch.generator.experiment;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import sketch.generator.ExhaustiveValueGenerator;

public class ExhaustiveValueGroupGenerator<T> extends ValueGroupGenerator<T> {

	public final ExhaustiveValueGenerator<T> generator;
	
	public ExhaustiveValueGroupGenerator(T...ts) {
		generator = new ExhaustiveValueGenerator<T>(ts);
	}
	
	public ExhaustiveValueGroupGenerator(Collection<T> ts) {
		List<T> list = new ArrayList<T>();
		for(T t : ts) {
			list.add(t);
		}
		generator = new ExhaustiveValueGenerator<T>(list);
	}
	
	@Override
	public void reset() {
		super.reset();
		this.generator.reset();
	}
	
	@Override
	public boolean hasNext() {
		return generator.hasNextValues();
	}

	@Override
	protected ValueGroup<T> generateNext() {
		List<T> list = generator.nextValue();
		ValueGroup<T> gen = null;
		if(super.current == null) {
			gen = this.createMultiValue();
		} else {
			gen = this.createMultiValue(list);
		}
		return gen;
	}

}
